define([
  'models/AlertMessage',
  'views/Item',
  'views/Modal', 
  'views/ConfirmCancelModal',
  'views/internals/FamiliarModal',
  'hbs!template/internals/familiar-item-embedded',
  'hbs!template/internals/confirm-delete-familiar-modal',
  'hbs!template/internals/success-familiar-destroy'
], function(AlertMessage, ItemView, Modal, ConfirmCancelModal, FamiliarModal, template, confirmTemplate, successDestroyTemplate){
  var FamiliarItem = ItemView.extend({
    tagName: "tr",
    
    events: {
      "click a[name=edit]":		"edit",
      "click a[name=delete]":		"confirmMessage"
    },
    
    initItem: function(options) {
      this.template = template;
      if(this.model) {
        this.model.bind("confirm_remove", this.confirm, this);
        this.model.bind("success_destroy", this.successDestroy, this);
      }
    },

    edit: function() {
      var modal = new FamiliarModal({model: this.model});
      modal.render();
    },

    confirmMessage: function() { // TODO
      var modal = new ConfirmCancelModal({
        model: this.model,
        template: confirmTemplate});
      modal.render();


/*      var message = new AlertMessage({model: this.model, title: "Esta seguro que desea eliminar el subscriptor?", about: this.model});
      this.addMessage(message);*/
    },

    successDestroy: function() {
      var modal = new Modal({template: successDestroyTemplate});
      modal.render();
      this.remove();
    },

    confirm: function() {
      this.model.destroy();
    }
    

  });

  return FamiliarItem;
});
